home *** CD-ROM | disk | FTP | other *** search
- '****************************************************************
- '* Instant Access Setup
- '* Copyright 1994 Instant Access, Ltd.
- '* Version 2.0
- '* Note from LJT: This is spaghetti code because
- '* 1.) It's Basic
- '* 2.) I started with Microsoft's Example and worked from there.
- '* I was only willing to re-org so much of it. Believe me
- '* it used to be alot worse than it is now but be warned it's
- '*****************************************************************
- '$INCLUDE 'setupapi.inc'
- '$INCLUDE 'msdetect.inc'
-
- 'Dialog ID's
- CONST WELCOME = 100
- CONST ASKQUIT = 200
- CONST DESTPATH = 300
- CONST EXITFAILURE = 400
- CONST EXITQUIT = 600
- CONST EXITSUCCESS = 700
- CONST OPTIONS = 800
- CONST APPHELP = 900
- CONST BADWIN = 1000
- CONST WIN30 = 1100
- CONST APPHELP2 = 1200
- CONST WELCUST = 1300
- CONST APPHELP1 = 1400
- CONST APPHELP3 = 1500
- CONST NOWIN30 = 1600
- CONST CUSTINST = 6200
- CONST TOOBIG = 6300
- CONST BADPATH = 6400
-
- 'Windows constants
- CONST VK_OPTION = 17
- CONST MASK_VALUE = 32768
-
- 'Bitmap ID
- CONST LOGO = 1
- CONST TRUE = 1
- CONST FALSE = 0
-
- 'File Types
- CONST APPFILES = 1
-
- 'General Global Variables
- GLOBAL SRCDIR$ 'CD Source Root Directory
- GLOBAL IADIR$ 'CD Source Instant Access (ia) Directory
- GLOBAL IAFDIR$ 'CD Source Instant Access (iafiles) Directory
- GLOBAL IA$
- GLOBAL DEST$ 'Destination Directory
- GLOBAL SRCDRIVE$ 'CD-ROM drive letter
- GLOBAL WINDRIVE$ 'Windows drive letter
- GLOBAL WINDIR$ 'Windows Directory
- GLOBAL WINSYS$ 'Windows System Directory
- GLOBAL CUSHION& 'Free disk space after installation
-
- 'CustInst list symbol names
- GLOBAL APPNEEDS$ 'Program File list costs per drive
- GLOBAL EXTRACOSTS$ 'List of extra costs to add per drive
- GLOBAL BIGLIST$ 'List of option files cost calc results (boolean)
-
- 'Dialog list symbol names
- GLOBAL CHECKSTATES$
- GLOBAL STATUSTEXT$
- GLOBAL DRIVETEXT$
-
- 'Global Library References
- GLOBAL CUIDLL$ 'Custom user interface dll
- GLOBAL HELPPROC$ 'Help dialog procedure
-
- 'Global Debugg
- GLOBAL DEBUG 'Global Debug flag
-
- 'Function & Subroutine Declarations
- DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
- DECLARE FUNCTION EnoughDiskSpace(level%) AS INTEGER
- DECLARE SUB AddOptFilesToCopyList (ftype%)
- DECLARE SUB RecalcOptFiles (ftype%)
- DECLARE SUB RecalcPath
- DECLARE SUB SetDriveStatus
- DECLARE SUB Install
-
- 'Direct Access to Windows Routines
- DECLARE FUNCTION GetAsyncKeyState Lib "User" ( vKey%) As INTEGER
-
- 'Setup Related Initialization
- DEBUG = FALSE
- CUIDLL$ = "mscuistf.dll"
- HELPPROC$ = "FHelpDlgProc"
-
- SetBitmap CUIDLL$, LOGO
- SetTitle "Instant Access Setup"
-
- 'Get CD ROM Source Directory & Read INF file
- szInf$ = GetSymbolValue("STF_SRCINFPATH")
- IF szInf$ = "" THEN
- szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
- END IF
- ReadInfFile szInf$
-
- 'Initialize General Global Variables
- SRCDIR$ = LCASE$(GetSymbolValue("STF_SRCDIR"))
- IADIR$ = MakePath(SRCDIR$,"ia")
- IAFDIR$ = MakePath(SRCDIR$,"iafiles")
- WINDIR$ = GetWindowsDir()
- WINSYS$ = GetWindowsSysDir()
- SRCDRIVE$ = LCASE$(MID$(SRCDIR$, 1, 1))
- WINDRIVE$ = LCASE$(MID$(WINDIR$, 1, 1))
-
- 'Custom Installation list symbols some of which may be used in
- 'Basic Installation as well
- CHECKSTATES$= "CheckItemsState"
- STATUSTEXT$ = "StatusItemsText"
- DRIVETEXT$ = "DriveStatusText"
-
- 'Disk cost list symbols
- APPNEEDS$ = "AppNeeds"
- EXTRACOSTS$ = "ExtraCosts"
- BIGLIST$ = "BigList"
-
- 'Create Items
- FOR i% = 1 TO 3 STEP 1
- AddListItem CHECKSTATES$, ""
- NEXT i%
- FOR i% = 1 TO 3 STEP 1
- AddListItem STATUSTEXT$, ""
- NEXT i%
- FOR i% = 1 TO 7 STEP 1
- AddListItem DRIVETEXT$, ""
- NEXT i%
- FOR i% = 1 TO 3 STEP 1
- AddListItem BIGLIST$, ""
- NEXT i%
- FOR i% = 1 TO 26 STEP 1
- AddListItem EXTRACOSTS$, "0"
- NEXT i%
-
- 'Check to see if Option Key is being held down, if so create DEBUG logfile
- IF (GetAsyncKeyState(VK_OPTION) AND MASK_VALUE) <> FALSE THEN
- DEBUG = TRUE
- OpenLogFile WINDRIVE$+":\IASETUP.LOG", 0
- WriteToLogFile "Option key is DOWN"
- END IF
-
- 'Throw up the Welcome Dialog.
- WELCOME:
- sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
- IF sz$ = "CONTINUE" THEN
- UIPop 1
- ELSE
- GOSUB ASKQUIT
- GOTO WELCOME
- END IF
-
- 'Initialize changable globals
- DEST$ = MakePath(WINDIR$,"instanta")
- Installation$ = "Standard"
- ReplaceListItem CHECKSTATES$, 1, "ON" 'Minimum Copy List
-
- '***************************************************************************
- '* Branch to proper section of code based on installation selection
- '***************************************************************************
- INSTALL_BRANCH:
- IF DEBUG=TRUE THEN
- WriteToLogFile Installation$ + " Installation"
- END IF
-
- '***************************************************************************
- '* Process through the Standard Installation Scenario
- '***************************************************************************
- STANDARD_INSTALLATION:
-
- 'First present user with destination path edit dialog
- GOSUB GETPATH
-
- 'Now compute what is possible to copy and set it up to be copied
- IF EnoughDiskSpace (APPFILES) = FALSE THEN
- ReplaceListItem CHECKSTATES$, APPFILES, "OFF"
- END IF
-
- '***************************************************************************
- '* Main Installation Routine
- '***************************************************************************
- INSTALLATION:
- Install
-
- '***************************************************************************
- '* Quit Setup
- '***************************************************************************
- QUIT:
- ON ERROR GOTO ERRQUIT
-
- IF ERR = 0 THEN
- dlg% = EXITSUCCESS
- ELSEIF ERR = STFQUIT THEN
- dlg% = EXITQUIT
- ELSE
- dlg% = EXITFAILURE
- END IF
-
- QUIT1:
- sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
- IF sz$ = "REACTIVATE" THEN
- GOTO QUIT1
- END IF
- UIPop 1
- END
-
- ERRQUIT:
- i% = DoMsgBox("Setup sources were corrupted, call 0181-200 0100!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
- END
-
- GETPATH:
- OLDDEST$ = DEST$
- SetSymbolValue "EditTextIn", DEST$
- SetSymbolValue "EditFocus", "END"
-
- GETPATH1:
- sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
- DEST$ = LCASE$(GetSymbolValue("EditTextOut"))
-
- IF sz$ = "CONTINUE" THEN
- IF IsDirWritable(DEST$) = 0 THEN
- GOSUB BADPATH
- GOTO GETPATH1
- END IF
- UIPop 1
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO GETPATH1
- ELSE
- IF Installation$ = "Standard" THEN
- GOSUB ASKQUIT
- GOTO GETPATH
- ELSE
- IF IsDirWritable(DEST$) = 0 THEN
- GOSUB BADPATH
- GOTO GETPATH1
- END IF
- UIPop 1
- DEST$ = OLDDEST$
- END IF
- ELSE
- UIPop 1
- END IF
- RETURN
-
- TOOBIG:
- sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
- IF sz$ = "REACTIVATE" THEN
- RecalcPath
- SetDriveStatus
- GOTO TOOBIG
- END IF
- UIPop 1
- RETURN
-
- BADPATH:
- sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
- IF sz$ = "REACTIVATE" THEN
- GOTO BADPATH
- END IF
- UIPop 1
- RETURN
-
- ASKQUIT:
- sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
- IF sz$ = "EXIT" THEN
- UIPopAll
- ERROR STFQUIT
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO ASKQUIT
- ELSE
- UIPop 1
- END IF
- RETURN
-
- '*************************************************************************
- '* Functions & Subroutines
- '*************************************************************************
- '*************************************************************************
- '** Purpose:
- '** Builds the copy list and performs all installation operations.
- '** Arguments:
- '** none.
- '** Returns:
- '** none.
- '*************************************************************************
- SUB Install STATIC
-
- CreateDir DEST$, cmoNone
-
- IF DEBUG = TRUE THEN
- WriteToLogFile "Prior to Installation"
- WriteToLogFile " Source Drive: "+SRCDRIVE$
- WriteToLogFile " Source Root Directory: "+SRCDIR$
- WriteToLogFile " IA Directory: "+IADIR$
- WriteToLogFile " IAFiles Directory: "+IAFDIR$
- WriteToLogFile " Destination Directory: "+DEST$
- WriteToLogFile " Windows Drive: "+WINDRIVE$
- WriteToLogFile " Windows Directory: "+WINDIR$
- WriteToLogFile "Status of Check Box State " + STR$(APPFILES) + " = " + GetListItem(CHECKSTATES$, APPFILES)
- END IF
-
- ClearCopyList
- AddOptFilesToCopyList APPFILES
-
- IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
- ini$ = MakePath(WINDIR$, "IA.INI")
- ' CopyFilesInCopyList Comment this out for now since we don't need to copy any files.
- CreateProgmanGroup "Instant Access", "", cmoNone
- ShowProgmanGroup "Instant Access", 1, cmoNone
- CreateProgmanItem "Instant Access", "Instant Access Browser", MakePath(SRCDIR$,"iabrowse.exe"), "", cmoOverwrite
- CreateIniKeyValue ini$, "Parameters", "CDPath", IAFDIR$, cmoOverwrite
- CreateIniKeyValue ini$, "Parameters", "InstantaPath", DEST$, cmoOverwrite
- ELSE
- sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
- IF sz$ = "REACTIVATE" THEN
- RecalcPath
- SetDriveStatus
- END IF
- UIPop 1
- ERR = STFQUIT
- END IF
-
- END SUB
-
- '*************************************************************************
- '** Purpose:
- '** Recalculates disk space for the given option files
- '** Arguments:
- '** level% - the level of options where each higher level i.e.
- '** OPTFILES2, encompasses all lower levels i.e. APPFILES & OPTFILES1
- '** Returns:
- '** none.
- '*************************************************************************
- FUNCTION EnoughDiskSpace (level%) STATIC AS INTEGER
-
- 'Add extra cost to Windows drive for ini/progman, etc.
- IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
- ndrive% = ASC(LCASE$(WINDRIVE$)) - ASC("a") + 1
- ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
- END IF
-
- 'Compute the cost of the level
- ClearCopyList
- IF level% >= 1 THEN
- AddOptFilesToCopyList APPFILES
- END IF
-
- IF GetCopyListCost(EXTRACOSTS$, "", "") = 0 THEN
- EnoughDiskSpace = TRUE
- IF DEBUG = TRUE THEN
- WriteToLogFile "EnoughDiskSpace at level "+STR$(level%)+" = TRUE"
- END IF
- ELSE
- EnoughDiskSpace = FALSE
- IF DEBUG = TRUE THEN
- WriteToLogFile "EnoughDiskSpace at level "+STR$(level%)+" = FALSE"
- END IF
- END IF
-
- END FUNCTION
-
- '*************************************************************************
- '** Purpose:
- '** Adds the specified option files to the copy list.
- '** Arguments:
- '** ftype% - type of files to add, one of the following:
- '** APPFILES, OPTFILES1, OPTFILES2, PRNTDRVR
- '** Returns:
- '** none.
- '*************************************************************************
- SUB AddOptFilesToCopyList (ftype%) STATIC
-
- SELECT CASE ftype%
- CASE APPFILES
- IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
- AddSectionFilesToCopyList "IA Files", SRCDIR$, DEST$
- END IF
- END SELECT
-
- END SUB
-
- '*************************************************************************
- '** Purpose:
- '** Recalculates disk space for the given option files and sets
- '** the status info symbol "StatusItemsText".
- '** Arguments:
- '** ftype% - type of files to add, one of the following:
- '** APPFILES, OPTFILES1, OPTFILES2
- '** Returns:
- '** none.
- '*************************************************************************
- SUB RecalcOptFiles (ftype%) STATIC
- CursorSave% = ShowWaitCursor()
- ClearCopyList
- AddOptFilesToCopyList ftype%
-
- 'Add extra cost to Windows drive for ini/progman, etc.
- fExtra% = 0
- IF ftype% = APPFILES THEN
- ListSym$ = APPNEEDS$
- IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
- ndrive% = ASC(LCASE$(WINDRIVE$)) - ASC("a") + 1
- ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
- fExtra% = 1
- END IF
- ELSEIF ftype% = OPTFILES1 THEN
- ListSym$ = OPT1NEEDS$
- ELSEIF ftype% = OPTFILES2 THEN
- ListSym$ = OPT2NEEDS$
- END IF
-
- StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
-
- cost& = 0
- FOR i% = 1 TO 26 STEP 1
- cost& = cost& + VAL(GetListItem(ListSym$, i%))
- NEXT i%
- ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024 ) + " K"
-
- IF StillNeed& > 0 THEN
- ReplaceListItem BIGLIST$, ftype%, "YES"
- ELSE
- ReplaceListItem BIGLIST$, ftype%, ""
- END IF
-
- IF fExtra% THEN
- ReplaceListItem EXTRACOSTS$, ndrive%, "0"
- END IF
- RestoreCursor CursorSave%
- ListSym$ = ""
-
- END SUB
-
-
- '*************************************************************************
- '**
- '** Purpose:
- '** Recalculates disk space and sets option status info according
- '** to the current destination path.
- '** Arguments:
- '** none.
- '** Returns:
- '** none.
- '*************************************************************************
- SUB RecalcPath STATIC
-
- CursorSave% = ShowWaitCursor()
-
- RecalcOptFiles APPFILES
- RecalcOptFiles OPTFILES1
- RecalcOptFiles OPTFILES2
-
- RestoreCursor CursorSave%
-
- END SUB
-
-
- '*************************************************************************
- '**
- '** Purpose:
- '** Sets drive status info according to latest disk space calcs.
- '** Arguments:
- '** none.
- '** Returns:
- '** none.
- '*************************************************************************
- SUB SetDriveStatus STATIC
-
- drive$ = LCASE$(MID$(DEST$, 1, 1))
- ndrive% = ASC(drive$) - ASC("a") + 1
- cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%))
- free& = GetFreeSpaceForDrive(drive$)
- CUSHION& = free& - cost&
- ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
- ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
- ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
-
- IF drive$ = LCASE$(WINDRIVE$) THEN
- ReplaceListItem DRIVETEXT$, 4, ""
- ReplaceListItem DRIVETEXT$, 5, ""
- ReplaceListItem DRIVETEXT$, 6, ""
- ELSE
- wdrive% = ASC(LCASE$(WINDRIVE$)) - ASC("a") + 1
- cost& = VAL(GetListItem(APPNEEDS$, wdrive%)) + VAL(GetListItem(OPT1NEEDS$, wdrive%)) + VAL(GetListItem(OPT2NEEDS$, wdrive%))
- IF cost& = 0 THEN
- ReplaceListItem DRIVETEXT$, 4, ""
- ReplaceListItem DRIVETEXT$, 5, ""
- ReplaceListItem DRIVETEXT$, 6, ""
- ELSE
- free& = GetFreeSpaceForDrive(WINDRIVE$)
- ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
- ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
- ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
- END IF
- END IF
- END SUB
-
-
- '*************************************************************************
- '**
- '** Purpose:
- '** Appends a file name to the end of a directory path,
- '** inserting a backslash character as needed.
- '** Arguments:
- '** szDir$ - full directory path (with optional ending "\")
- '** szFile$ - filename to append to directory
- '** Returns:
- '** Resulting fully qualified path name.
- '*************************************************************************
- FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
- IF szDir$ = "" THEN
- MakePath = szFile$
- ELSEIF szFile$ = "" THEN
- MakePath = szDir$
- ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
- MakePath = szDir$ + szFile$
- ELSE
- MakePath = szDir$ + "\" + szFile$
- END IF
- END FUNCTION
-
-